﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PreeRegisterModel;
using System.Data;
using PreeRegisterDAL;

namespace PreeRegisterBLL
{
    public class MedInfoBLL
    {
        /// <summary>
        /// 获取医院实际就诊量信息
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public static MedInfoResponseModel MedInfoUpdate(MedInfoRequestModel request)
        {
            try
            {

                //反序列化
                //if (json.Trim() == "")
                //    throw new Exception("请求字符串不能为空！");

                //校验输入
                string ErrMsg = "";
                if (!VerifyInput(request, ref ErrMsg))
                {
                    return null;
                }

                //获取预约执行情况信息
                MedInfoResponseModel medInfoResponseModel = GetMedInfo(request);

                return medInfoResponseModel;
            }
            catch (Exception err)
            {
                throw;
            }
        }

        /// <summary>
        /// 校验输入参数
        /// </summary>
        /// <param name="request"></param>
        /// <param name="ErrMsg"></param>
        /// <returns></returns>
        private static bool VerifyInput(MedInfoRequestModel request, ref string ErrMsg)
        {
            try
            {
                if (request.workid.Trim() == "")
                {
                    ErrMsg = "排班ID不能为空！";
                    return false;
                }
                return true;
            }
            catch (Exception err)
            {

                throw;
            }
        }

        /// <summary>
        /// 根据排班ID获取医院实际就诊量  
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        private static MedInfoResponseModel GetMedInfo(MedInfoRequestModel request)
        {
            try
            {

                MedInfoResponseModel medInfoResponseModel = new PreeRegisterModel.MedInfoResponseModel();

                DataSet ds = MedInfoDAL.GetMedInfo(request.workid);

                medInfoResponseModel.acount = ds.Tables[0].Rows[0]["num"].ToString();

                return medInfoResponseModel;
            }
            catch (Exception err)
            {

                throw;
            }
        }
    }
}
